/**
 * Class: BlinkingDot
 *
 * Purpose: 
 *
 * Created: Jan 27, 2010 @ 9:37:01 AM
 * @author Ken Scott
 */
package org.openfantasia.ps.shape;

import org.openfantasia.ps.particle.Particle;
import org.openfantasia.ps.shape.Dot;
import org.openfantasia.ui.PColor;
import org.openfantasia.ui.PFrame;

public class BlinkingDot extends Dot {

	protected long period = 1000;


	public BlinkingDot(PFrame frame) {
		super(frame);
	}


	public BlinkingDot(PFrame frame, float weight) {
		super(frame, weight);
	}


	public BlinkingDot(PFrame frame, float weight, long period) {
		super(frame, weight);
		this.period = period;
	}


	public void draw(Particle particle) {
		boolean on = ((System.currentTimeMillis() / period) & 1) == 1;
		PColor color = on ? particle.getFillColor() : PColor.INVISIBLE;
		PColor scaledColor = color.scale((float) particle.getBrightness());
		PColor solidifiedColor = scaledColor.opacify((float) particle.getOpacity());

		frame.strokeWeight(weight);
		frame.stroke(solidifiedColor);
		frame.point(particle.getPosition());
		frame.strokeWeight(1);
	}
}
